Page({
  data:{
    name:'立即登录'
  },
  onLoad:function(){
    var user = wx.getStorageSync("user");
    console.log("me");
    if(user){
      this.setData({name:user.name});
    }
  }, 
  onShow:function(){
    var user = wx.getStorageSync("user");
    
    if(user){
      this.setData({name:user.name});
      var app = getApp()
      app.globalData.username=user.name
    }
  },
  piao:function(e){
    var loginState = e.currentTarget.dataset.text+""
    console.log(loginState)
    if('立即登录'==loginState){
      wx.showToast({
        title: '请先登录',
        icon: 'none',
        duration: 1500
    })    
    }else{
      wx.showToast({
        title: '显示中',
        icon: 'none',
        duration: 1500
    })  
    wx.navigateTo({
      url: '../piao/piao?username='+loginState
    })
    }
  },
  login:function(){
    wx.navigateTo({
      url: '../login/login'
    })
  }
})